package tracer

import (
	"context"
	"fmt"
	"log"
	"os"

	trace "github.com/micro/go-micro/v2/debug/trace"
)

/*
 * use for trace
 */
type MyTracer struct{}

var logger = log.New(os.Stdout, "tracer", log.Ldate|log.Ltime|log.Lshortfile)

// strart
func (t MyTracer) Start(ctx context.Context, name string) (context.Context, *trace.Span) {
	logger.Printf("name[%s]: %#v\n", name, ctx)
	fmt.Printf("name[%s]: %#v\n", name, ctx)
	return ctx, &trace.Span{Name: name}
}

// Finish the trace
func (t MyTracer) Finish(s *trace.Span) error {
	logger.Println(s)
	return nil
}

// Read the traces
func (t MyTracer) Read(opts ...trace.ReadOption) (s []*trace.Span, err error) {

	return
}
